<template>
<view class="page-wrapper">
<!-- <tabbar :tabbar="tabbar"></tabbar> -->
<shopPage></shopPage>
</view>
</template>

<script>
import common from '../../utils/common.js'
var head = require('../../utils/customHead.js');
var app = getApp();
var _this;
import shopPage from "../../appComponent/shopPage/shopPage";

export default {
  data() {
    return { 
		tabbar: {},
		showArrow: false,
		pageOpenTimes: 0,
	};
  },

  // 分享
  onShareAppMessage() {
	let pageLink = '/pages/shop_index/index'
	pageLink = common.addShareParam(pageLink)
    if (_this.config.config.shop_wxapp_share_title != '' && _this.config.config.shop_wxapp_share_img != '') {
      return {
        title: _this.config.config.shop_wxapp_share_title,
        imageUrl: _this.config.config.shop_wxapp_share_img,
        path: pageLink
      };
    } else {
      return {
        path: pageLink
      };
    }
  },

  // 生命周期函数--监听页面加载
  onLoad: function (options) {
    _this = this;
    app.globalData.isPay = false;
	// 是否是识别二维码打开
    if (options.scene) {
      var scene = decodeURIComponent(options.scene);
      console.log("scene is ", scene);
      wx.navigateTo({
        url: '/pages/shop_new/shopDetail/shopDetail?' + scene
      });
    }
	
	// #ifdef H5
	if (options.viewpage) {
		//H5滚动条
		var style = document.createElement("style");
		style.type = "text/css";
		var css =
			"::-webkit-scrollbar{width: 2px;height: 8px;background-color: #f6f8f8;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;}::-webkit-scrollbar-thumb {background-color:rgba(45, 41, 41, 0.5);-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;}";
		if (style.styleSheet) {
			style.styleSheet.cssText = css;
		} else {
			style.appendChild(document.createTextNode(css));
		}
		document.getElementsByTagName("head")[0].appendChild(style);

		//禁止点击
		/*var div = document.createElement('div');
		div.setAttribute('style', 'position:fixed;top:0;left:0;width:100%;height:100%;z-index:99999;');
		var bo = document.body;
		bo.insertBefore(div, bo.lastChild);*/
	}
	// #endif
	
	// 是否是店铺详情页分享打开
    if (options.store_id && options.backgroundColor && options.frontColor) {
      wx.navigateTo({
        url: `/pages/shop_new/shopDetail/shopDetail?store_id=${options.store_id}&backgroundColor=${options.backgroundColor}&frontColor=${options.frontColor}`
      });
    }

    app.homeIsRedirect();
	
  },
  onShow: function () {
    // 页面被展示
	console.log('22222222快店首页')
	common.editTabbar('', function(tabbar){
		_this.tabbar = tabbar
	});
    _this.pageOpenTimes++;
	uni.$emit('pageShow', _this.pageOpenTimes)
	
	// #ifdef H5
	setWxShare();
	// #endif
  },
  onUnload () {
	  uni.$off('pageShow')
  },
  components: {
    shopPage
  }
};
// 微信h5分享
const setWxShare = () => {
	common.getConfig(function(data){
		let pageLink = `${common.requestDomain}packapp/${common.wxapp_type}/pages/shop_index/index`;
		pageLink = common.addShareParam(pageLink)
		let shareWxLink = pageLink;
		var shareData = {
			title: data.config.shop_wxapp_share_title,
			desc: common.changeTxt('点击立马查看更多店铺与优惠'),
			sendFriendLink: shareWxLink,
			share_img: data.config.shop_wxapp_share_img
		};
		common.setWxShare(shareData);
	})
};
</script>
<style>
.page-wrapper{
	height: 100%;
	box-sizing: border-box;
	padding-bottom: 98rpx;
	padding-bottom: calc(98rpx + env(safe-area-inset-bottom));
	padding-bottom: calc(98rpx + constant(safe-area-inset-bottom));
}
</style>